<?php

namespace IDock\Insurance\JDAL\Response;

use IDock\Http\Response;
use IDock\IDock\IDockEnums;
use IDock\Insurance\JDAL\JDALEnums;
use IDock\Printer\VehicleModelPrinter;
use IDock\Printer\VehiclePrinter;

class VehicleInfoCheckResponse extends AllJDALResponse
{

    public $biResultStats;

    public $biResultMsg;

    public $ciResultStats;

    public $ciResultMsg;

    public function printerInit(): Response
    {
        $result = $this->get('ruleHandlerResult',[]);

        $commHandlerResultCode = $result['commHandlerResultCode'] ?? '';

        $tplHandlerResultCode = $result['tplHandlerResultCode'] ?? '';

        if ($commHandlerResultCode ) {

            if ($commHandlerResultCode == '0000') {
                $this->biResultStats = true;
            } else {
                $this->biResultStats = false;
                $this->biResultMsg = $result['commHandlerResultMsg'] ?? '';
            }
        }

        if ($tplHandlerResultCode) {
            if ($tplHandlerResultCode == '0000') {
                $this->ciResultStats = true;
            } else {
                $this->ciResultStats = false;
                $this->ciResultMsg = $result['tplHandlerResultMsg'] ?? '';
            }
        }

        if ($this->biResultMsg or $this->ciResultMsg) {
            $this->setError($this->biResultMsg ."\r\n".$this->ciResultMsg);
        }

        return $this;
    }
}
